package org.duang.http.common;

import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;

public abstract class HttpMessage {

	private Map<String, String> headers = new HashMap<String, String>();
	private InputStream content;
	private long contentLength;
	
	public HttpMessage() {
		super();
	}

	public HttpMessage(Map<String, String> headers, InputStream content, long contentLength) {
		super();
		this.headers = headers;
		this.content = content;
		this.contentLength = contentLength;
	}

	public Map<String, String> getHeaders() {
		return headers;
	}

	public void setHeaders(Map<String, String> headers) {
		this.headers = headers;
	}
	
	public void addHeader(String key, String value) {
		this.headers.put(key, value);
	}

	public InputStream getContent() {
		return content;
	}

	public void setContent(InputStream content) {
		this.content = content;
	}

	public long getContentLength() {
		return contentLength;
	}

	public void setContentLength(long contentLength) {
		this.contentLength = contentLength;
	}
	
	public void close() throws IOException {
		if(null != content) {
			content.close();
			content = null;
		}
	}
}
